#ifndef __EEPROM_H__
#define __EEPROM_H__
#include "gd32f10x.h"

#define EEPROM_DEVICE_ADDRESS       (0xA0)
#define EEPROM_OPS_WRITE            (EEPROM_DEVICE_ADDRESS & ~0X01)
#define EEPROM_OPS_READ             (EEPROM_DEVICE_ADDRESS | 0X01)

#define AT24C02
// #define AT24C04
// #define AT24C08
// #define AT24C16
// #define AT24C32
// #define AT24C64

#if defined (AT24C02)
#define EEPROM_PAGE_SIZE            (8)
#elif defined (AT24C04) || defined (AT24C08) || defined (AT24C16)
#define EEPROM_PAGE_SIZE            (16)
#elif defined (AT24C32) || defined (AT24C64)
#define EEPROM_PAGE_SIZE            (32)
#endif
void eeprom_write_one_byte(const uint8_t addr, const uint8_t data);
void eeprom_write_bytes(const uint16_t addr, const uint8_t* const buf, const uint16_t len);
void eeprom_read_bytes(const uint8_t addr, uint8_t* const buf, const uint16_t len);
void eeprom_self_test(void);
#endif
